document.querySelector(".tel").onblur = checkTel;

function checkTel() {
    var ele = document.querySelector(".tel")
    var tel = ele.value;
    console.log("手机号:" + tel);


    if (tel == "" || tel == null) {
        ele.style.opacity = "0";
        //消息提示
        document.querySelector(".tel_msg").innerText = "请输入手机号";
        return false;

    } else if (!tel.match(/^\d{11}$/)) {
        document.querySelector(".tel_msg").innerText = "";
        return true;
    } else {
        document.querySelector(".tel_msg").innerText = "";
        return true;
    }
}

document.querySelector(".tel").onclick = clickTel;

function clickTel() {
    var ele = document.querySelector(".tel");
    // ele.value = "";
    ele.style.color = 'black';
    ele.style.opacity = "1";
}

document.querySelector(".email").onclick = clickEmail;

function clickEmail() {
    var ele = document.querySelector(".email");
    ele.style.opacity = "1";
    ele.style.color = 'black';
}

document.querySelector(".email").onblur = checkEmail;

function checkEmail() {
    var ele = document.querySelector(".email");

    var email = ele.value;
    console.log("邮箱:" + email);

    if (email == "" || email == null) {
        ele.style.opacity = "0";

        //消息提示
        document.querySelector(".email_msg").innerText = "邮箱不能为空";
        return false;

    } else if (!email.match(/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/)) {
        document.querySelector(".email_msg").innerText = "请输入正确的邮箱";
        return false;

    } else {
        document.querySelector(".email_msg").innerText = "";
        return true;
    }
}

document.querySelector(".password").onclick = clickPassword;

function clickPassword() {
    var ele = document.querySelector(".password");
    ele.style.opacity = "1";
    ele.style.color = 'black';


}


document.querySelector(".password").onblur = checkPassword;

function checkPassword() {

    var ele = document.querySelector(".password");
    var password = ele.value;
    // ele.style.opacity="1";
    console.log("密码:" + password);


    if (password == "" || password == null) {
        ele.style.opacity = "0";
        //消息提示
        document.querySelector(".password_msg").innerText = "请输入密码";
        return false;

    } else if (!password.match(/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$/)) {
        document.querySelector(".password_msg").innerText = "密码必须由数字,字母特殊符号中至少两种组成";
        return false;

    } else if (!password.match(/^.{6,20}$/)) {
        document.querySelector(".password_msg").innerText = "密码必须为6-20位";
        return false;
    } else {
        document.querySelector(".password_msg").innerText = "";
        return true;
    }

}

document.querySelector(".repassword").onclick = clickRePassword;

function clickRePassword() {
    var ele = document.querySelector(".repassword");
    ele.style.opacity = "1";
    ele.style.color = 'black';
}


document.querySelector(".repassword").onblur = checkRePassword;

function checkRePassword() {
    var repassword = document.querySelector(".repassword").value;
    console.log("确认密码:" + repassword);

    var ele = document.querySelector(".repassword");

    var password = document.querySelector(".password").value;
    console.log("密码:" + password);

    if (repassword == "" || repassword == null) {
        ele.style.opacity = "0";
        //消息提示
        document.querySelector(".repassword_msg").innerText = "请确认密码";
        return false;

    } else if (repassword != password) {
        document.querySelector(".repassword_msg").innerText = "密码不一致";
        return false;
    } else {
        document.querySelector(".repassword_msg").innerText = "";
        return true;
    }

}

document.querySelector(".code").onclick = clickCode;

function clickCode() {
    var ele = document.querySelector(".code");
    ele.style.opacity = "1";
    ele.style.color = 'black';
}

document.querySelector(".code").onblur = checkCode;

function checkCode() {
    var ele = document.querySelector(".code")
    var code = ele.value;
    console.log("验证码:" + code);

    if (code == "" || code == null) {
        ele.style.opacity = "0";

        //消息提示
        document.querySelector(".code_msg").innerText = "请输入验证码";
        return false;

    } else if (code != 1234) {
        document.querySelector(".code_msg").innerText = "验证码错误";
        return false;
    } else {
        document.querySelector(".code_msg").innerText = "";
        return true;
    }
}


// document.querySelector(".registForm").onsubmit = function () {
//     return checkTel() && checkEmail() && checkPassword() && checkCode() && checkRePassword();
// }